import Reflux from "reflux"
import GUtils from "@/utils";
import BaseAction ,{addDefaultListerns} from "@/base/BaseAction";

const prefix ="/order/washOrder/";
const api = {
    search: prefix+"search",
    create: prefix+"create",
    edit: prefix+"edit",
    detail:  prefix+"detail",
    statusCount: prefix+"statusCount",
    refund: prefix+"refund",
};

const createAction = () => {
    const Action = Reflux.createActions({
        ...BaseAction,
        statusCount: {asyncResult: true},
        refund: {asyncResult: true},
        preRefund:{}
    });

    addDefaultListerns(Action, api);
    Action.statusCount.listen(function (so) {
        GUtils.jsonAjax.post(api.statusCount, so).then(this.completed, this.failed);
    });
    Action.refund.listen(function (so, callback) {
        GUtils.jsonAjax.post(api.refund, so).then(this.completed.bind(this,callback), this.failed);
    });

    return Action;
};

export {api, createAction}